package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.entity.ResignationCertificate;
import com.amsp.oa.oademo.service.ResignationCertificateService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@Api(tags = "离职证明管理")
@RestController
@RequestMapping("/api/resignation-certificate")
public class ResignationCertificateController {

    @Autowired
    private ResignationCertificateService resignationCertificateService;

    @ApiOperation("分页查询离职证明")
    @GetMapping("/page")
    public Page<ResignationCertificate> getPage(
            @ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam("每页数量") @RequestParam(defaultValue = "10") Integer pageSize,
            @ApiParam("员工姓名") @RequestParam(required = false) String employeeName,
            @ApiParam("身份证号") @RequestParam(required = false) String idNumber) {
        return resignationCertificateService.getPage(pageNum, pageSize, employeeName, idNumber);
    }

    @ApiOperation("根据ID查询离职证明")
    @GetMapping("/{id}")
    public ResignationCertificate getById(@ApiParam("ID") @PathVariable Long id) {
        return resignationCertificateService.getById(id);
    }

    @ApiOperation("保存或更新离职证明")
    @PostMapping("/save")
    public boolean save(@ApiParam("离职证明列表") @RequestBody List<ResignationCertificate> list) {
        return resignationCertificateService.saveOrUpdateBatch(list);
    }

    @ApiOperation("删除离职证明")
    @DeleteMapping("/delete")
    public boolean delete(@ApiParam("ID列表") @RequestBody List<Long> ids) {
        return resignationCertificateService.deleteByIds(ids);
    }
}